package ProjectTeam39.Domains;
//import User.Gender;
import junit.framework.TestCase;
import org.junit.BeforeClass;

import ProjectTeam39.GUITest.LoginFrame;
import ProjectTeam39.GUITest.TestWindow;

import java.util.ArrayList;

public class JUnitMain extends TestCase{
	UserList ul;
	
	
	@BeforeClass public void setUp(){
		ul = new UserList("Doctor's Office");
	}
	
	public void testLogin(){
		int returned;
		LoginFrame lframe = new LoginFrame(ul);
		//valid Patient login
		returned = lframe.doLogin("myusername","mypassword");
		assertEquals(1, returned);
		
		//invalid Patient login
		returned = lframe.doLogin("myusername","notmypassword");
		assertEquals(0, returned);
		
		//valid Nurse Login
		returned = lframe.doLogin("nursejoy", "password");
		assertEquals(2, returned);
		
		//invalid Nurse login
		returned = lframe.doLogin("nursejoy", "notpassword");
		assertEquals(0, returned);
		
		//valid Doctor Login
		returned = lframe.doLogin("doctorwho", "password");
		assertEquals(3, returned);
		
		//invalid Doctor Login
		returned = lframe.doLogin("doctorwho", "notpassword");
		assertEquals(0, returned);
		
		//valid Admin login
		returned = lframe.doLogin("glados", "password");
		assertEquals(4, returned);
		
		//invalid Admin login
		returned = lframe.doLogin("glados", "notpassword");
		assertEquals(0, returned);
		
	}
	/**
	 * Locks out user with an error window if successful
	 */
	
/*	public void testLoginLockOut(){
		TestWindow tw = new TestWindow();
		LoginFrame lframe = tw.getFrame();
		for(int i=0;i<3;i++){
			lframe.doLogin("notauser", "withafakepw");
		}
		int results = lframe.getAttempts();
		assertEquals(3, results);
	} */
	
	public void testCreatePatient(){
		long phone = new Long("7708769823");
		Patient p = new Patient("John Smith", phone, "My address is here", null, "jsmith3", "password");
		assertNotNull(p);
	}
	
	public void testReadPatient(){
		UserList u2 = new UserList("Doctor's Office");
		Clientelle c = u2.getClientelle();
		long phone = new Long("7708769823");
		Patient p = new Patient("John Smith", phone, "My address is here", null, "jsmith3", "password");
		c.createClient(p);
		ArrayList<Patient> patients = c.getUsers();
		Patient pcheck = patients.get(1);
		assertEquals(p.getName(), pcheck.getName());
	}
	
	public void testUpdatePatient(){
		Clientelle c = ul.getClientelle();
		long phone = new Long("7708769823");
		Patient p = new Patient("John Smith", phone, "My address is here", null, "jsmith3", "password");
		c.createClient(p);
		p.setSecurityStatus(37);
		assertEquals(37,p.getSecurityStatus());
	}
/*	
	public void testDeletePatient(){
		UserList u2 = new UserList("Doctor's Office");
		Clientelle c = u2.getClientelle();
		long phone = new Long("7708769823");
		Patient p = new Patient("John Smith", phone, "My address is here", null, "jsmith3", "password");
		c.createClient(p);
		c.deletePatient("John Smith");
		assertEquals(1,c.getUsers().size());
	}
	
	public void testCreateNurse(){
		long phone = new Long("7708769823");
		Nurse n = new Nurse("Nurse Smith","nurse12","nurseword", phone, "My address is here", null, null);
		assertNotNull(n);
	}
	
	public void testReadNurse(){
		Employees e = ul.getEmployees();
		long phone = new Long("7708769823");
		Nurse n = new Nurse("Nurse Smith","nurse12","nurseword", phone, "My address is here", null, null);
		e.createNurse(n);
		
		Nurse nursecheck = e.getNurse("Nurse Smith");
		assertEquals(n.getName(),nursecheck.getName());
	}
	
	public void testUpdateNurse(){
		Employees e = ul.getEmployees();
		long phone = new Long("7708769823");
		Nurse n = new Nurse("Nurse Smith","nurse12","nurseword", phone, "My address is here", null, null);
		e.createNurse(n);
		
		n.setSecurityStatus(37);
		assertEquals(37,n.getSecurityStatus());
	}
	
	public void testDeleteNurse(){
		Employees e = ul.getEmployees();
		long phone = new Long("7708769823");
		Nurse n = new Nurse("Nurse Smith","nurse12","nurseword", phone, "My address is here", null, null);
		e.createNurse(n);
		
		e.deleteNurse("Nurse Smith");
		ArrayList<Nurse> nurses = e.getNurses();
		assertEquals(0,nurses.size());
	}
	
	public void testCreateDoctor(){
		long phone = new Long("7708769823");
		Nurse n = new Nurse("Nurse Smith","nurse12","nurseword", phone, "My address is here", null, null);
		assertNotNull(n);
	}
	
	public void testReadDoctor(){
		Employees e = ul.getEmployees();
		long phone = new Long("7708769823");
		Nurse n = new Nurse("Nurse Smith","nurse12","nurseword", phone, "My address is here", null, null);
		e.createNurse(n);
		
		Nurse nursecheck = e.getNurse("Nurse Smith");
		assertEquals(n.getName(),nursecheck.getName());
	}
	
	public void testUpdateDoctor(){
		Employees e = ul.getEmployees();
		long phone = new Long("7708769823");
		Doctor d = new Doctor("Dr. Smith","doc13","docword", phone, "My address is here", null, null,"Aches");
		e.createDoctor(d);
		
		d.goToMedSchool("Pains");
		assertEquals("Pains",d.getSpecialty());
	}
	
	public void testDeleteDoctor(){
		Employees e = ul.getEmployees();
		long phone = new Long("7708769823");
		Doctor d = new Doctor("Dr. Smith","doc13","docword", phone, "My address is here", null, null,"Aches");
		e.createDoctor(d);
		
		e.deleteDoctor("Dr. Smith");
		ArrayList<Doctor> doctors = e.getDoctors();
		assertEquals(0,doctors.size());
	}
	
	public void testLookupByName(){
		Clientelle c = ul.getClientelle();
		long phone = new Long("7708769823");
		Patient p = new Patient("John Smith", phone, "My address is here", null, "jsmith3", "password");
		c.createClient(p);
		
		assertTrue(c.findPatient("John Smith"));
	}*/
	
	public void testCreateAppointment1(){
		//UserList ul = new UserList()
		String[] docs = {"John Doe", "Jane Doe"};
		AppointmentCalender apptcal = new AppointmentCalender(31, Date.Day.MONDAY, docs);
		long phone = new Long("3980005");
		Doctor doc = new Doctor("John Doe", "jd","pw", phone, "addr",
				apptcal, null, "oncology");
		Patient p = new Patient("someone", phone, "address", 
				null, "so", "pw");
		Appointment appt = apptcal.scheduleAppt(p, 9, new Date(15, Date.Month.JANUARY), "sick", doc);
		assertNotNull(appt);
	}
	
	public void testCreateAppointment2(){
		String[] docs = {"John Doe", "Jane Doe"};
		AppointmentCalender apptcal = new AppointmentCalender(31, Date.Day.TUESDAY, docs);
		Doctor doc = new Doctor("John Doe", "jd","pw", 3980005, "addr",
				apptcal, ul, "oncology");
		Patient p = new Patient("someone", 3980005, "address", 
				null, "so", "pw");
		Appointment appt = apptcal.scheduleAppt(p, 9, new Date(15, Date.Month.JANUARY), "sick", doc);
		assertNotNull(appt);
	}
	
	public void testReadAppointment(){
		String[] docs = {"John Doe", "Jane Doe"};
		AppointmentCalender apptcal = new AppointmentCalender(31, Date.Day.MONDAY, docs);
		Doctor doc = new Doctor("John Doe", "jd","pw", 3980005, "addr",
				apptcal, ul, "oncology");
		Patient p = new Patient("someone", 3980005, "address", 
				null, "so", "pw");
		Appointment appt = apptcal.scheduleAppt(p, 9, new Date(15, Date.Month.JANUARY), "sick", doc);
		System.out.println(appt.toString());
		assertNotNull(appt);
	}
	
	public void testCreateAppointment3(){
		String[] docs = {"John Doe", "Jane Doe"};
		AppointmentCalender apptcal = new AppointmentCalender(31, Date.Day.WEDNESDAY, docs);
		Doctor doc = new Doctor("John Doe", "jd","pw", 3980005, "addr",
				apptcal, ul, "oncology");
		Patient p = new Patient("someone", 3980005, "address", 
				null, "so", "pw");
		Appointment appt = apptcal.scheduleAppt(p, 9, new Date(15, Date.Month.JANUARY), "sick", doc);
		assertNotNull(appt);
	}
	
	public void testCreateAppointment4(){
		String[] docs = {"John Doe", "Jane Doe"};
		AppointmentCalender apptcal = new AppointmentCalender(31, Date.Day.THURSDAY, docs);
		Doctor doc = new Doctor("John Doe", "jd","pw", 3980005, "addr",
				apptcal, ul, "oncology");
		Patient p = new Patient("someone", 3980005, "address", 
				null, "so", "pw");
		Appointment appt = apptcal.scheduleAppt(p, 9, new Date(15, Date.Month.JANUARY), "sick", doc);
		assertNotNull(appt);
	}
	
	public void testCreateAppointment5(){
		String[] docs = {"John Doe", "Jane Doe"};
		AppointmentCalender apptcal = new AppointmentCalender(31, Date.Day.FRIDAY, docs);
		Doctor doc = new Doctor("John Doe", "jd","pw", 3980005, "addr",
				apptcal, ul, "oncology");
		Patient p = new Patient("someone", 3980005, "address", 
				null, "so", "pw");
		Appointment appt = apptcal.scheduleAppt(p, 9, new Date(15, Date.Month.JANUARY), "sick", doc);
		assertNotNull(appt);
	}
	
	public void testCreateAppointment6(){
		String[] docs = {"John Doe", "Jane Doe"};
		AppointmentCalender apptcal = new AppointmentCalender(31, Date.Day.SATURDAY, docs);
		Doctor doc = new Doctor("John Doe", "jd","pw", 3980005, "addr",
				apptcal, ul, "oncology");
		Patient p = new Patient("someone", 3980005, "address", 
				null, "so", "pw");
		apptcal.print();
		Object appt = apptcal.scheduleAppt(p, 9, new Date(15, Date.Month.JANUARY), "sick", doc);
		if (appt!=null) {
			System.out.println(appt.toString());
			System.out.println("appt isnt null");
		}
		assertNull(appt);
	}
	
	public void testCreateAppointment7(){
		String[] docs = {"John Doe", "Jane Doe"};
		AppointmentCalender apptcal = new AppointmentCalender(31, Date.Day.SUNDAY, docs);
		Doctor doc = new Doctor("John Doe", "jd","pw", 3980005, "addr",
				apptcal, ul, "oncology");
		Patient p = new Patient("someone", 3980005, "address", 
				null, "so", "pw");
		Appointment appt = apptcal.scheduleAppt(p, 9, new Date(15, Date.Month.JANUARY), "sick", doc);
		assertNull(appt);
	}
	
	public void testUpdateAppointment(){
		
	}
	
	public void testDeleteAppointment(){
		String[] docs = {"John Doe", "Jane Doe"};
		Date d = new Date(15, Date.Month.JANUARY);
		AppointmentCalender apptcal = new AppointmentCalender(31, Date.Day.MONDAY, docs);
		Doctor doc = new Doctor("John Doe", "JD","pw", 3980005, "addr",
				apptcal, ul, "oncology");
		Patient p = new Patient("someone", 3980005, "address", 
				null, "so", "pw");
		Appointment appt = apptcal.scheduleAppt(p, 9, d, "sick", doc);
		appt = apptcal.searchAppt(9, d, doc);
		appt = null;
		assertNull(appt);

	}
	
	public void testCreateTreatmentRecord(){
		Nurse n = new Nurse("Betty","Betty123","pass",7290110, "123 Broad St", null, null);
		Doctor d = new Doctor("Dr. Bob", "Bob1", "pass3",4454455, "321 Center St.", null, null, "ENT");
		//Patient p = new Patient("Seth Dubin",5393080,"4259 Old Bridge Lane",null,null,"sdubin3","pass1");
		DoctorsOrders doco = new DoctorsOrders(null, "EKG", "Come back tomorrow.", "Penicillin", "Stay safe.");
		int weight = 156;
		int height = 45;
		int temp = 98; 
		int bloodPressure = 70;
		String symptoms = "bloody nose";
		
		TreatmentRecord t = new TreatmentRecord(null, d, n, doco, height, weight, temp,
												bloodPressure, symptoms);
		MedicalInfo mi = new MedicalInfo("CVS 203", "BlueCross", "no allergies");
		mi.addTreatment(t);
		
		assertEquals(t, mi.getTreatmentRecord(t));
		assertEquals(156,t.getWeight());
		assertEquals("bloody nose", t.getSymptoms());
	}
	
	public void testUpdateTreatmentRecord(){
		Nurse n = new Nurse("Betty","Betty123","pass",7290110, "123 Broad St", null, null);
		Doctor d = new Doctor("Dr. Bob", "Bob1", "pass3", 4454455, "321 Center St.", null, null, "ENT");
		//Patient p = new Patient("Seth Dubin",5393080,"4259 Old Bridge Lane",null,null,"sdubin3","pass1");
		DoctorsOrders doco = new DoctorsOrders(null, "EKG", "Come back tomorrow.", "Penicillin", "Stay safe.");
		int weight = 156;
		int height = 45;
		int temp = 98; 
		int bloodPressure = 70;
		String symptoms = "bloody nose";
		
		TreatmentRecord t = new TreatmentRecord(null, d, n, doco, height, weight, temp,
												bloodPressure, symptoms);
		MedicalInfo mi = new MedicalInfo("CVS 203", "BlueCross", "no allergies");
		mi.addTreatment(t);
		
		t.setSymptoms("Diarhea");
		t.setWeight(57);
		assertEquals("Diarhea",t.getSymptoms());
		assertEquals(57,t.getWeight());
	}
	
	/*public void testDeleteTreatmentRecord(){
		Nurse n = new Nurse("Betty","Betty123","pass",7290110, "123 Broad St", null, null);
		Doctor d = new Doctor("Dr. Bob", "Bob1", "pass3", 4454455, "321 Center St.", null, null, "ENT");
		//Patient p = new Patient("Seth Dubin",5393080,"4259 Old Bridge Lane",null,null,"sdubin3","pass1");
		DoctorsOrders doco = new DoctorsOrders(null, "EKG", "Come back tomorrow.", "Penicillin", "Stay safe.");
		int weight = 156;
		int height = 45;
		int temp = 98; 
		int bloodPressure = 70;
		String symptoms = "bloody nose";
		
		TreatmentRecord t = new TreatmentRecord(null, d, n, doco, height, weight, temp,
												bloodPressure, symptoms);
		MedicalInfo mi = new MedicalInfo("CVS 203", "BlueCross", "no allergies");
		mi.addTreatment(t);
		
		mi.deleteTreatmentRecord(t);
		
		assertEquals(null,t);
	}*/
	
	public void testCreateDoctorOrders(){
		Nurse n = new Nurse("Betty","Betty123","pass",7290110, "123 Broad St", null, null);
		Doctor d = new Doctor("Dr. Bob", "Bob1", "pass3", 4454455, "321 Center St.", null, null, "ENT");
		//Patient p = new Patient("Seth Dubin",5393080,"4259 Old Bridge Lane",null,null,"sdubin3","pass1");
		DoctorsOrders doco = new DoctorsOrders(null, "EKG", "Come back tomorrow.", "Penicillin", "Stay safe.");
		int weight = 156;
		int height = 45;
		int temp = 98; 
		int bloodPressure = 70;
		String symptoms = "bloody nose";
		
		TreatmentRecord t = new TreatmentRecord(null, d, n, doco, height, weight, temp,
												bloodPressure, symptoms);
		MedicalInfo mi = new MedicalInfo("CVS 203", "BlueCross", "no allergies");
		mi.addTreatment(t);
		
		assertEquals(doco,t.getDoctorsOrders());
	}
	
	public void testReadDoctorOrders(){
		Nurse n = new Nurse("Betty","Betty123","pass",7290110, "123 Broad St", null, null);
		Doctor d = new Doctor("Dr. Bob", "Bob1", "pass3", 4454455, "321 Center St.", null, null, "ENT");
		//Patient p = new Patient("Seth Dubin",5393080,"4259 Old Bridge Lane",null,null,"sdubin3","pass1");
		DoctorsOrders doco = new DoctorsOrders(null, "EKG", "Come back tomorrow.", "Penicillin", "Stay safe.");
		int weight = 156;
		int height = 45;
		int temp = 98; 
		int bloodPressure = 70;
		String symptoms = "bloody nose";
		
		TreatmentRecord t = new TreatmentRecord(null, d, n, doco, height, weight, temp,
												bloodPressure, symptoms);
		MedicalInfo mi = new MedicalInfo("CVS 203", "BlueCross", "no allergies");
		mi.addTreatment(t);
	
		assertEquals("Stay safe.",doco.listInstructions());
	}
	
	public void testUpdateDoctorOrders(){
		Nurse n = new Nurse("Betty","Betty123","pass",7290110, "123 Broad St", null, null);
		Doctor d = new Doctor("Dr. Bob", "Bob1", "pass3", 4454455, "321 Center St.", null, null, "ENT");
		//Patient p = new Patient("Seth Dubin",5393080,"4259 Old Bridge Lane",null,null,"sdubin3","pass1");
		DoctorsOrders doco = new DoctorsOrders(null, "EKG", "Come back tomorrow.", "Penicillin", "Stay safe.");
		int weight = 156;
		int height = 45;
		int temp = 98; 
		int bloodPressure = 70;
		String symptoms = "bloody nose";
		
		TreatmentRecord t = new TreatmentRecord(null, d, n, doco, height, weight, temp,
												bloodPressure, symptoms);
		MedicalInfo mi = new MedicalInfo("CVS 203", "BlueCross", "no allergies");
		mi.addTreatment(t);
		
		doco.setFollowUp("Call us tomorrow.");
		
		assertEquals("Call us tomorrow.",doco.listFollowUp());
	}
	
	/*public void testDeleteDoctorOrders(){
		Nurse n = new Nurse("Betty","Betty123","pass",7290110, "123 Broad St", null, null);
		Doctor d = new Doctor("Dr. Bob", "Bob1", "pass3", 4454455, "321 Center St.", null, null, "ENT");
		//Patient p = new Patient("Seth Dubin",5393080,"4259 Old Bridge Lane",null,null,"sdubin3","pass1");
		DoctorsOrders doco = new DoctorsOrders(null, "EKG", "Come back tomorrow.", "Penicillin", "Stay safe.");
		int weight = 156;
		int height = 45;
		int temp = 98; 
		int bloodPressure = 70;
		String symptoms = "bloody nose";
		
		TreatmentRecord t = new TreatmentRecord(null, d, n, doco, height, weight, temp,
												bloodPressure, symptoms);
		MedicalInfo mi = new MedicalInfo("CVS 203", "BlueCross", "no allergies");
		mi.addTreatment(t);
		
		t.deleteDoctorsOrders(doco);
		
		assertEquals(null,t.getDoctorsOrders());
		
	}*/
	
	public void testLoadSave(){
		
	}
	
	public void testInvoices(){
		Nurse n = new Nurse("Betty","Betty123","pass",7290110, "123 Broad St", null, null);
		Doctor d = new Doctor("Dr. Bob", "Bob1", "pass3", 4454455, "321 Center St.", null, null, "ENT");
		//Patient p = new Patient("Seth Dubin",5393080,"4259 Old Bridge Lane",null,null,"sdubin3","pass1");
		DoctorsOrders doco = new DoctorsOrders(null, "EKG, tetanus shot, drug alysis, bun", "Come back tomorrow.", "Penicillin", "Stay safe.");
		int weight = 156;
		int height = 45;
		int temp = 98; 
		int bloodPressure = 70;
		String symptoms = "bloody nose";
		
		TreatmentRecord t = new TreatmentRecord(null, d, n, doco, height, weight, temp,
												bloodPressure, symptoms);
		PatientInvoice pi = new PatientInvoice(t);
		MedicalInfo mi = new MedicalInfo("CVS 203", "BlueCross", "no allergies");
		mi.addTreatment(t);
		
		pi.listInvoice();
		
	}
}
